<?php

/**
 * Gere les exceptions levees par le package Bundle
 *
 * @category   McCube
 * @package    Bundle
 * @author     Leiha Sellier <leiha.sellier@gmail.com>
 * @license    http://creativecommons.org/licenses/by/3.0/  CC BY 3.0
 * @link       http://code.google.com/p/mechanics-cubes/
 */
class McCube_Bundle_Exception
     extends McCube_Exception{

    public function __construct($message, $errorCode, $extras=array()){
        parent::__construct($message, $errorCode, $extras, false);
        $this->_extraDatas = $extras;
        $this->buildRealMessage();
    }

    public function buildRealMessage(){
        switch($this->message){
            default                  : $txt = $this->message; break;
            case 'File:Tpl'          : $txt = 'Template File';break;
            case 'File:TplForm'      : $txt = 'Template Form File';break;
            case 'File:Model'        : $txt = 'Model File';break;
            case 'Controller:Action' : $txt = 'Action';break;
            case 'Config:Form'       : $txt = 'Config of Form';break;
            case 'Config:Entity'     : $txt = 'Config of Entity';break;
        }


        $this->message = $txt.' [ ';

        if(isset($this->_extraDatas['name']))
            $this->message .= '[@value@'.$this->_extraDatas['name'].'@]';

        elseif(isset($this->_extraDatas['file']))
            $this->message .= '[@value@'.$this->_extraDatas['file'].'@]';

        $this->message  .=' ] '.$this->getLitteralCode();

        $this->message .= "\n".' - Bundle [ '.
            '[@bundle@'.$this->_extraDatas['bundle'].'@]'
        .' ]';
    }
}